import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)


import index from "../pages/index.vue"
import search from "../pages/search.vue"
import detail from "../pages/detail.vue"

import car from "../views/car.vue"
import message from "../views/message.vue"
import my from "../views/my.vue"

const router = new VueRouter({
  routes:[
    {
      path:"/index",
      component:index,
      // 配二级路由，谁里面有二级就在谁里面加children
      //二级路由不加/
      children:[
        {
          path:"/message",
          component:message
        },
        {
          path:"/car",
          component:car
        },
        {
          path:"/my",
          component:my
        },
        //二级路由的重定向，不加*
        {
          path:"",
          redirect:"/message"
        }
      ]
    },
    {
      path:"/search",
      component:search
    },
    {
      path:"/detail",
      component:detail
    },
    //重定向
    {
      path:"*",
      redirect:"/index"
    }
  ]
})

export default router
